package com.link.base.base.accnt.service;

import javax.annotation.Resource;

import com.link.core.basic.service.ServiceException;
import com.link.base.base.accnt.dao.mybatis.mapper.EquipmentMapper;
import org.springframework.stereotype.Service;
import com.link.base.base.accnt.model.Equipment;
import com.link.core.basic.dao.mapper.BasicMapper;
import com.link.core.basic.service.BasicServiceImpl;

import java.util.List;

/**
 * @author: 王艳
 * @date: 2018-12-12
 * @comments:
 */
@Service
public class EquipmentServiceImpl extends BasicServiceImpl<Equipment> implements EquipmentService {

    @Resource
    private EquipmentMapper equipmentMapper;
    
    @Override
    public BasicMapper<Equipment> getBasicMapper() {
        return equipmentMapper;
    }

    @Override
    public void beforUpsert(Equipment entity) throws Exception {
        Equipment equipment = new Equipment();
        equipment.setId(entity.getId());
        equipment.setEquipmentNum(entity.getEquipmentNum());
        List<Equipment> list = equipmentMapper.queryAll(equipment);
        if (list.size() > 0) {
            throw new ServiceException("ACCT-040");
        }
    }
}

